package com.betterjr.modules.loan;

import static com.betterjr.common.web.ControllerExceptionHandler.exec;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.web.Servlets;

@Controller
@RequestMapping(value = "/Scf/IndexPage")
public class IndexPageWorkPlatformController {
    private static final Logger logger = LoggerFactory.getLogger(RequestController.class);

    @Reference(interfaceClass = IScfRequestService.class)
    private IScfRequestService scfRequestService;

    /**
     * 
     * @Title: statisticSupplyBeforeFinanceSituation 
     * @Description: TODO(统计供应商过去十二个月的历史融资情况) 
     * @param @param request
     * @param @param currentDate
     * @param @return 参数说明 
     * @return String 返回类型 
     * @throws 
     * @author chenlq
     * @date 2017年11月23日 下午6:35:22
     */
    @RequestMapping(value = "/statisticSupplyHistoryFinanceSituation", method = RequestMethod.POST)
    public @ResponseBody String statisticSupplyBeforeFinanceSituation(HttpServletRequest request, String currentDate) {
        final Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("统计融资情况查询,入参：" + anMap.toString());
        return exec(() -> scfRequestService.webStatisticSupplyHistoryFinanceSituation(anMap), "融资情况查询统计失败！", logger);
    }

    /**
     * 
     * @Title: statisticFuturePaymentSituation 
     * @Description: TODO(查询统核心企业未来资金情况) 
     * @param @param request
     * @param @param currentDate
     * @param @return 参数说明 
     * @return String 返回类型 
     * @throws 
     * @author chenlq
     * @date 2017年11月23日 下午6:31:54
     */
    @RequestMapping(value = "/coreEnterpriseFuturePay", method = RequestMethod.POST)
    public @ResponseBody String coreEnterpriseFuturePay(HttpServletRequest request, String currentDate) {
        final Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("统计融资情况查询,入参：" + anMap.toString());
        return exec(() -> scfRequestService.webStatisticFuturePaymentSituation(anMap), "融资情况查询统计失败！", logger);
    }

    /**
     * 
     * @Title: statisticFutureRepayment 
     * @Description: TODO(统计未来回款情况，查询出未来12个月，计算出每个月的待回款总和) 
     * @param @param request
     * @param @return 参数说明 
     * @return String 返回类型 
     * @throws 
     * @author chenlq
     * @date 2017年11月22日 下午5:51:15
     */
    @RequestMapping(value = "/statisticFutureRepayment", method = RequestMethod.POST)
    public @ResponseBody String statisticFutureRepayment(HttpServletRequest request) {
        final Map<String, Object> anMap = Servlets.getParametersStartingWith(request, "");
        logger.info("统计查询,入参：" + anMap.toString());
        return exec(() -> scfRequestService.webStatisticFutureRepayment(anMap), "回款月份统计失败！", logger);
    }
}
